package www.dashu.com.domain;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.Formula;
import www.dashu.com.domain.base.BaseVo;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

@Data
@Entity
@Table(name="oms_order_item")
public class OmsOrderItem extends BaseVo implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("")
    @Id
    private Long id;

    @ApiModelProperty("订单id")
    @Column(name = "order_id")
    private Long orderId;

    @ApiModelProperty("")
    @Column(name = "product_id")
    private Long productId;

    @ApiModelProperty("")
    @Column(name = "product_pic")
    private String productPic;

    @ApiModelProperty("")
    @Column(name = "product_name")
    private String productName;

    @ApiModelProperty("")
    @Column(name = "product_brand")
    private String productBrand;

    @ApiModelProperty("销售价格")
    @Column(name = "product_price")
    private Double productPrice;

    @ApiModelProperty("商品分类")
    @Column(name = "product_category_name")
    private Long productCategoryName;

    @ApiModelProperty("商品促销名称")
    @Column(name = "promotion_name")
    private String promotionName;

    @ApiModelProperty("商品促销分解金额")
    @Column(name = "promotion_amount")
    private Double promotionAmount;

    @ApiModelProperty("优惠券优惠分解金额")
    @Column(name = "coupon_amount")
    private Double couponAmount;

    @ApiModelProperty("积分优惠分解金额")
    @Column(name = "integration_amount")
    private Double integrationAmount;

    @ApiModelProperty("该商品经过优惠后的分解金额")
    @Column(name = "real_amount")
    private Double realAmount;

    @ApiModelProperty("商品销售属性:[{key:颜色,value:颜色},{key:容量,value:4G}]")
    @Column(name = "product_attr")
    private String productAttr;

    @ApiModelProperty("所属商户")
    @Formula("(select s.name from sys_company s where s.id = company )")
    private String companyName;

    @Column(name = "company")
    private Long company;

    @ApiModelProperty("所属应用")
    @Formula("(select s.name from sys_app s where s.id = app_id )")
    private String appName;

    @Column(name = "app_id")
    private Long appId;

    @ApiModelProperty("创建时间")
    @Column(name = "create_time")
    private Date createTime;

    @ApiModelProperty("更新时间")
    @Column(name = "update_time")
    private Date updateTime;


    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", orderId=").append(orderId);
        sb.append(", productId=").append(productId);
        sb.append(", productPic=").append(productPic);
        sb.append(", productName=").append(productName);
        sb.append(", productBrand=").append(productBrand);
        sb.append(", productPrice=").append(productPrice);
        sb.append(", productCategoryName=").append(productCategoryName);
        sb.append(", promotionName=").append(promotionName);
        sb.append(", promotionAmount=").append(promotionAmount);
        sb.append(", couponAmount=").append(couponAmount);
        sb.append(", integrationAmount=").append(integrationAmount);
        sb.append(", realAmount=").append(realAmount);
        sb.append(", productAttr=").append(productAttr);
        sb.append(", company=").append(company);
        sb.append(", appId=").append(appId);
        sb.append(", createTime=").append(createTime);
        sb.append(", updateTime=").append(updateTime);
        sb.append("]");
        return sb.toString();
    }

}